<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ page errorPage="/pages/errorpage.jsp" %>

<html:html>
<head>
<title><bean:message key="courses.title"/></title>
<link rel="stylesheet" href="<%=request.getContextPath() %>/default.css" type="text/css">
<html:base/>
</head>
<body>

<div id="header">
	<div id="logo">
		<h1>
			<html:img width="40" src="../images/EMPTY.GIF"/>
			<html:link page="/pages/home.jsp">Textbook Crossroads</html:link>
		</h1>
		<h2>Team 14 - LoneTree</h2>
	</div>
	<div id="menu">
		<ul>
			<li>
			<logic:notPresent name="logged_in_user_in_session">
			<html:link page="/pages/home.jsp">Home</html:link>
			</logic:notPresent>
			<logic:present name="logged_in_user_in_session">
			<logic:equal value="false" name="logged_in_user_in_session" property="admin">
			<html:link action="/PrepForMyBooks">Dashboard</html:link>
			</logic:equal>
			<logic:equal value="true" name="logged_in_user_in_session" property="admin">
			<html:link page="/pages/admindashboard.jsp">Dashboard</html:link>
			</logic:equal>
			</logic:present>
			</li>
			<li><html:link page="/pages/books.jsp">Books</html:link></li>
			<li class="active"><html:link page="/pages/courses.jsp">Courses</html:link></li>
			<li><html:link page="/pages/about.jsp">About</html:link></li>
			<li class="logon">
			<logic:notPresent name="logged_in_user_in_session">
			<html:link page="/pages/logon.jsp">LogIn</html:link>
			</logic:notPresent>
			<logic:present name="logged_in_user_in_session">
			<html:link action="/logout">LogOut</html:link>
			</logic:present>
			</li>
		</ul>
	</div>
</div>

<logic:notPresent name="org.apache.struts.action.MESSAGE" scope="application">
  <font color="red">
    ERROR:  Application resources not loaded -- check servlet container
    logs for error messages.
  </font>
</logic:notPresent>

<div id="content">
	<div id="sidebar">
		<div id="categories">
			<div id="archives" class="boxed">
				<logic:notPresent name="logged_in_user_in_session">
						<h2>Contributors</h2>
				</logic:notPresent>
			
				<logic:present name="logged_in_user_in_session">			
					<logic:equal value="true" name="logged_in_user_in_session" property="admin">						
						<h2>Admin Actions</h2>										
					</logic:equal>
				
					<logic:equal value="false" name="logged_in_user_in_session" property="admin">
						<h2>MyActions</h2>						
					</logic:equal>
				</logic:present>
				
				<div class="content">
					<logic:notPresent name="logged_in_user_in_session">
						<ul>
							<li>Andrew Lee</li>
							<li>Bojan Martin</li>
							<li>Dimeji Omikunle</li>
							<li>Minghui Yu</li>
						</ul>
					</logic:notPresent>
					
					<logic:present name="logged_in_user_in_session">
						<ul>
							<logic:equal value="false" name="logged_in_user_in_session" property="admin">
					    		<li><html:link page="/PrepForMyBooks.do?manage=books">Manage MyBooks</html:link></li>
					            <li><html:link page="/PrepForMyBooks.do?manage=sections">Manage MySections</html:link></li>
					            <li><html:link action="/UpdateMyProfile">Update MyProfile</html:link></li>
							</logic:equal>
							
							<logic:equal value="true" name="logged_in_user_in_session" property="admin">
					    		<li><html:link href="bookadmin.jsp"><bean:message
					            key="adminbook.link"/></html:link></li>
					            
					            <li><html:link action="/AdminCourses"><bean:message
					            key="admincourses.link"/></html:link></li>
					            
					            <li><html:link action="/AdminAccounts"><bean:message
					            key="adminaccounts.link"/></html:link></li>
					            
					            <li><html:link action="/AdminComments"><bean:message
					            key="admincomments.link"/></html:link></li>
							</logic:equal>
						</ul>	
					</logic:present>
				</div>
			</div>
		</div>
	</div>

	<div id="posts">
		<div class="post">
			<h2 class="title"><bean:message key="courses.heading"></bean:message></h2>
			<div class="meta">
				<p class="date">Search:</p>
			</div>
			<div class="story">
			<p>
			<form action="../SearchCourse.do">
	<strong>Please enter keywords to search by course title (leave blank to ignore):</strong><br>
	<input name="title" type="text" size="20"/><br><br>
	<strong>Please enter department and/or number to search by course code (leave blank to ignore):</strong><br>
	<input name="dept" type="text" size="4" maxlength="4"/>&nbsp;&nbsp;<input name="number" type="text" size="3" maxlength="3"/><br><br>
	<input type="submit" value="Search" /><br><br>
	<logic:present name="message">
	<span style="color: #FF0000"><bean:write name="message" /></span>
	</logic:present>
	</form></p>
	</div>
	<logic:present name="courses">
	<div class="meta">
				<p class="date">Results:</p>
			</div>
			<div class="story">
			<p>
  <logic:notEmpty name="courses">
  <ol>
  <logic:iterate id="course" name="courses" indexId="cnt">
   <li><html:link page="/ViewCourseDetails.do" paramName="course" paramProperty="courseId" paramId="courseId">
	<bean:write name="course" property="courseId.courseIdString" />:&nbsp;&nbsp;<bean:write name="course" property="title" /></html:link></li>
	</logic:iterate>  
	</ol>
  </logic:notEmpty>
    
    <logic:empty name="courses">
    <i>Search did not return any results</i>
    </logic:empty>
    </p>
    </div>
  
  </logic:present>
  </div>
	</div>
</div>

<div id="footer">
	<p id="copy">&copy;2007 LoneTree.</p>
	<p> (Andrew Lee | Bojan Martin | Dimeji Omikunle | Minghui Yu)</p>
</div>
</body>
</html:html>